﻿using System;
using System.Globalization;

namespace Kaleida.ServiceMonitor.Framework
{
    public class Duration
    {
        private readonly double value;
        private readonly string suffix;

        public static Duration Parse(string text)
        {
            return text.ToDuration();
        }

        public Duration(double value, string suffix)
        {
            this.value = value;
            this.suffix = suffix;
        }

        public double Value
        {
            get { return value; }
        }

        public string Suffix
        {
            get { return suffix; }
        }

        public override string ToString()
        {
            return suffix == "" ? value.ToString(CultureInfo.InvariantCulture) : string.Format("{0} {1}", value, suffix);
        }
    }
}
